package com.medicine.sys.controller;

import com.medicine.common.base.ResponseData;
import com.medicine.sys.entity.Department;
import com.medicine.sys.entity.Role;
import com.medicine.sys.param.DepartmentParam;
import com.medicine.sys.param.RoleParam;
import com.medicine.sys.service.DepartmentService;
import com.medicine.sys.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "部门或科室管理")
@RestController
@RequestMapping("/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @ApiOperation(value="部门或科室列表查询")
    @GetMapping("")
    public ResponseData pageList(DepartmentParam departmentParam){
        return ResponseData.success("查询成功！",departmentService.selectPageList(departmentParam));
    }

    @ApiOperation(value="查询全部部门或科室")
    @GetMapping("/list")
    public ResponseData list(){
        return ResponseData.success("查询成功！",departmentService.selectList());
    }

    @ApiOperation(value="部门或科室新增")
    @PostMapping
    public ResponseData install(Department department){
        departmentService.install(department);
        return ResponseData.success("新增成功！");
    }


    @ApiOperation(value="部门或科室修改")
    @PutMapping
    public ResponseData update(Department department){
        departmentService.install(department);
        return ResponseData.success("修改成功！");
    }

    @ApiOperation(value="部门或科室详情查询")
    @GetMapping("/{id}")
    public ResponseData list(@PathVariable String id){
        return ResponseData.success("查询成功！",departmentService.getId(id));
    }
}
